package com.wedo.mall.activity.payment;

import android.os.Bundle;
import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.e.library.activity.EActivity;
import com.wedo.mall.R;
import com.wedo.mall.entity.Agent;
import com.wedo.mall.util.WUrl;

import java.util.Locale;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @author lxy
 * @time 2018/1/17  15:14
 */
public class PaymentSuccessActivity extends EActivity {

    @BindView(R.id.tv_amount) TextView tv_amount;
    @BindView(R.id.tv_payee) TextView tv_payee;
    @BindView(R.id.iv_head) ImageView iv_head;

    @Override
    protected int layout() {
        return R.layout.activity_payment_success;
    }

    @Override
    protected void onActivityCreated(Bundle state) {
        Bundle bundle = getIntent().getExtras();
        String amount = bundle.getString("amount");
        Agent agent = bundle.getParcelable("agent");

        double value = 0.00;
        if(!TextUtils.isEmpty(amount)) {
            value = Double.parseDouble(amount);
        }

        tv_amount.setText(String.format(Locale.ENGLISH,"%.2f",value));
        tv_payee.setText(agent.agent_name);
        Glide.with(this).load(WUrl.url(agent.logo)).error(R.drawable.place_holder_agent).placeholder(R.drawable.place_holder_agent).diskCacheStrategy(DiskCacheStrategy.ALL).into(iv_head);
    }

    @OnClick(R.id.btn_complete)
    protected void onCompleteClick(){
        defaultFinish();
    }
}
